package com.woniuxy.stage3demo.mapper.lyl;

import com.woniuxy.stage3demo.bean.lyl.SysMessageBean;
import com.woniuxy.stage3demo.pageHelper.PageRequest;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface SysMessageMapper {
    /**
     * 分页查询
     * @param
     * @return
     */
  /*  @Results({
            @Result(id=true,property = "id",column = "id",javaType = Integer.class),
            @Result(property = "sysMsgNo",column = "sys_msg_no",javaType = String.class),
            @Result(property = "sysMsgTitle",column = "sys_msg_title",javaType = String.class),
            @Result(property = "sysMsgContent",column = "sys_msg_content",javaType = String.class),
            @Result(property = "createTime",column = "create_time",javaType = Date.class),

            @Result(property = "staff",column = "staff_id",javaType = StaffBean.class,one =
            @One(select = "com.woniuxy.stage3demo.mapper.lyl.StaffMapper.getOneById",fetchType = FetchType.LAZY)),
            @Result(property = "delFlag",column = "del_flag",javaType = Integer.class)
    })
*/
   /* @Select("select * from sys_message where staff_id=1")*/
    List<SysMessageBean> findAllByParams(@Param("p") PageRequest request,@Param("s")SysMessageBean sysMessageBean);
    /**
     * 存储新消息
     * @param sysMessageBean 系统消息
     */
    @Insert("insert into sys_message (sys_msg_no,sys_msg_title,sys_msg_content,create_time,staff_id,del_flag) values" +
            "(#{s.sysMsgNo},#{s.sysMsgTitle},#{s.sysMsgContent},#{s.createTime},#{s.staffBean.id},1)")
    void saveSysMessageBean(@Param("s") SysMessageBean sysMessageBean);
    /**
     * 删除系统消息
     * @param id 系统消息id
     */
    @Update("update sys_message set del_flag = 0 where id=#{id}")
    void deleteOneSysMessageBean(@Param("id")Long id);
    /**
     * 条件查询系统消息
     * @param sysMsgTitle 系统消息标题
     * @param
     */
    /*@Results({
            @Result(id=true,property = "id",column = "id",javaType = Integer.class),
            @Result(property = "sysMsgNo",column = "sys_msg_no",javaType = String.class),
            @Result(property = "sysMsgTitle",column = "sys_msg_titel",javaType = String.class),
            @Result(property = "sysMsgContent",column = "sys_msg_content",javaType = String.class),
            @Result(property = "createTime",column = "create_time",javaType = Date.class),
            @Result(property = "delFlag",column = "del_flag",javaType = Integer.class),
            @Result(property = "staff",column = "staff_id",javaType = StaffBean.class,one =
            @One(select = "com.woniuxy.stage3demo.mapper.lyl.StaffMapper.getOneById",fetchType = FetchType.LAZY))
    })
    @Select("<script>" +
            "select s.id,s.sys_msg_no,s.sys_msg_title,s.sys_msg_content,s.create_time,s.staff_id,s.del_flag from sys_msg as s ,staff where " +
            "<if test='sysMsgTitle!=null'>" +
            "s.sys_msg_title=#{sysMsgTitle}," +
            "</if>" +
            "<if test='name!=null'>" +
            "staff.name=#{name}," +
            "</if>" +
            "and del_flag=0" +
            "</script>")
    List<SysMessageBean> selectSysMessageBeanByTitleAndName(PageRequest request,String sysMsgTitle,String name );
*/


}
